#include "stdafx.h"
#include "st_blinn_env.h"
st_blinn_env::st_blinn_env()
{
	
}

st_blinn_env::~st_blinn_env()
{
	
}

void st_blinn_env::init()
{
	D3DVERTEXELEMENT9*	_vertex_element=new D3DVERTEXELEMENT9[6];
	D3DVERTEXELEMENT9 decl_Model_RigidBasis[] =
	{
		{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, //size 12
		{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 }, //size 12
		{ 0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, //size 8
		{ 0, 32, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 }, //size 12
		{ 0, 44, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 }, //size 12
		D3DDECL_END()
	};
	for(int i=0;i<6;++i)
	{
		_vertex_element[i]=decl_Model_RigidBasis[i];
	}
	set_vertex_element(_vertex_element);
	set_vertex_size(sizeof(decl_Model_RigidBasis));

	//init others

	

}

void st_blinn_env::default_set_args( LTEffectShader *pEffect,const LTShaderDeviceState &ShaderDeviceState )
{

	ShaderDeviceState.GetMatrix(LTShaderDeviceState::LTMatrixType::MATRIXTYPE_VIEW,false, m_view) ;
	ShaderDeviceState.GetMatrix(LTShaderDeviceState::LTMatrixType::MATRIXTYPE_WORLD0, false, m_world);
	ShaderDeviceState.GetMatrix(LTShaderDeviceState::LTMatrixType::MATRIXTYPE_VIEWPROJECTION, false, m_view_proj);
	pEffect->SetMatrix("World",*m_world);
	pEffect->SetMatrix("ViewProj",*m_view_proj);
	m_world->Inverse() ;
	pEffect->SetMatrix("WorldInv", *m_world) ;
	m_view->Inverse() ;
	pEffect->SetMatrix("ViewInv", *m_view) ;

}

